<template>
  <el-dialog
    title="查看账户流水"
    :close-on-click-modal="false"
    :visible.sync="visible"
  >
    <el-table
      :data="dataForm"
      ref="dataForm"
      border
      v-loading="dataFormLoading"
      style="width: 100%"
    >
      <el-table-column
        prop="number"
        header-align="center"
        align="center"
        width="120"
        label="单据编号"
      >
       <template slot-scope="scope">
　　　　　　<el-button type="text" @click="addOrUpdateHandle(scope.row.number)">{{scope.row.number}}</el-button>
        </template>
      </el-table-column>
      <el-table-column
        prop="type"
        header-align="center"
        align="center"
        label="类型"
      >
      </el-table-column>
      <el-table-column
        prop="supplierName"
        header-align="center"
        align="center"
        label="单位信息"
      >
      </el-table-column>
      <el-table-column
        prop="changeAmount"
        header-align="center"
        align="center"
        width="100"
        label="金额"
      >
      </el-table-column>
      <el-table-column
        prop="balance"
        header-align="center"
        align="center"
        label="余额"
      >
      </el-table-column>
      <el-table-column
        prop="operTime"
        header-align="center"
        align="center"
        label="单据日期"
      >
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update
      v-if="addOrUpdateVisible"
      ref="addOrUpdate"
    ></add-or-update>
  </el-dialog>
</template>

<script>
import AddOrUpdate from "./account-add-or-updatein";
import { isEmail, isMobile } from "@/utils/validate";
export default {
  data() {
    return {
      parentValue: [],
      value1: "",
      value2: "",
      dataFormLoading: false,
      addOrUpdateVisible: false,
      value: "",
      visible: false,
      roleList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataForm:[],
    };
  },
  components: {
    AddOrUpdate,
  },
  methods: {
    // 弹出框
    addOrUpdateHandle(id) {
      // console.log(id)
      this.addOrUpdateVisible = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id);
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    handleChange(value) {
      console.log(value);
    },
    init(id,initialAmount) {
      // console.log(id);
      this.visible = true;
      this.dataForm.id = id || 0;
      if (this.dataForm.id) {
        this.$http({
          url: this.$http.adornUrl("/account/findAccountInOutList"),
          method: "get",
          params: this.$http.adornParams(
            {
              currentPage: this.pageIndex,
              pageSize: this.pageSize,
              accountId:id,
              initialAmount,
            },
            false
          ),
        }).then(({ data }) => {
          // console.log(data);
          this.dataForm = data.data.list;
          this.totalPage = data.data.totalCount;
        });
      }
    },
  },
};
</script>
